/*
 * Copyright:  2018 smarabbit studio.
 *
 *  Licensed under the Confluent Community License; you may not use this file
 *  except in compliance with the License.  You may obtain a copy of the License at
 *
 *  http://www.confluent.io/confluent-community-license
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 *  WARRANTIES OF ANY KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations under the License.
 *
 *  @作   者： 黄开晖 (117227773@qq.com)
 *  @日   期:  2021年6月5日
 */
package com.massyframework.beanskin.sample.domain;

import java.io.Serializable;
import java.util.Objects;

import com.massyframework.beanskin.sample.ToDoItem;
import com.massyframework.beanskin.sample.ToDoItemBuilder;

/**
 * 待办事项
 * @author huangkh
 *
 */
public class ToDoItemDomain implements ToDoItem,  Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -9138242491245193404L;
	
	private long id;
	private String title;
	private String description;

	/**
	 * 
	 */
	protected ToDoItemDomain() {
		
	}
	
	protected ToDoItemDomain(Builder builder) {
		this.id = Objects.requireNonNull(builder.id, "\"id\" cannot be null.");
		this.title = Objects.requireNonNull(builder.title, "\"title\" cannot be null.");
		this.description = Objects.requireNonNull(builder.description, "\"description\" cannot be null.");
	}

	/**
	 * 编号
	 * @return {@link long}
	 */
	public long getId() {
		return id;
	}

	/**
	 * 标题
	 * @return {@link String}
	 */
	public String getTitle() {
		return title;
	}

	/**
	 * 说明
	 * @return {@link String}
	 */
	public String getDescription() {
		return description;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (int) (id ^ (id >>> 32));
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ToDoItemDomain other = (ToDoItemDomain) obj;
		if (id != other.id)
			return false;
		return true;
	}
	
	/**
	 * 创建构建器
	 * @return {@link Builder}
	 */
	public static Builder newBuilder() {
		return new Builder();
	}
	
	/**
	 * 构建器
	 */
	public static class Builder implements ToDoItemBuilder{
		private Long id;
		private String title;
		private String description;
		
		/**
		 * 设置编号
		 * @param value {@link Long}
		 * @return {@link Builder}
		 */
		public Builder id(Long value) {
			this.id = value;
			return this;
		}
		
		/**
		 * 设置标题
		 * @param value {@link String}
		 * @return {@link Builder}
		 */
		public Builder title(String value) {
			this.title = value;
			return this;
		}
		
		/**
		 * 设置说明
		 * @param value {@link String}
		 * @return {@link Builder}
		 */
		public Builder description(String value) {
			this.description = value;
			return this;
		}
		
		/**
		 * 创建待办事项
		 * @return {@link ToDoItemDomain}
		 */
		public ToDoItemDomain build() {
			return new ToDoItemDomain(this);
		}
	}

}
